package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {
    /**
     * 查询对应分类id下的餐品数量
     * @param id
     * @return
     */
    @Select("select count(id) from dish where category_id = #{id};")
    Integer countByCate(Long id);

    /**
     * 新建菜品
     * @param dish
     */
    @AutoFill(OperationType.INSERT)
    void addDish(Dish dish);

    /**
     * 菜品分页查询
     * @param dto
     * @return
     */
    Page<DishVO> pagesGetDish(DishPageQueryDTO dto);

    /**
     * 根据id获取菜品
     * @param id
     * @return
     */
    Dish getById(Long id);

    /**
     * 根据id批量删除
     * @param ids
     */
    void deleteDish(List<Long> ids);

    /**
     * 更新菜品
     * @param dish
     */
    @AutoFill(OperationType.UPDATE)
    void modifyDish(Dish dish);

    /**
     * 根据分类id查询菜品
     * @param id
     * @return
     */
    List<DishVO> getByCate(Long id);

    @Select("select * from dish where category_id = #{categoryId} and status = #{status}")
    List<Dish> list(Dish dish);
}
